package com.errorfinding.yuan;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
import cn.hutool.http.HttpRequest;

import java.util.Date;

public class test5 {
    public static void main(String[] args) {
        //首页宝箱
        String _device = "Yz-"+ MD5.create().digestHex("129591529").substring(0,5);
        String User_Agent = "Mozilla/5.0 (Linux; Android 12; "+_device+") AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBS/2.37.1";

        //DS
        String n = "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs";
        int t = Math.round(new Date().getTime() / 1000);
        //double r = Math.floor(Math.random() * 900000 + 100000);
        int r = RandomUtil.randomInt(100000, 200000);
        String b = "";
        String q = "role_id=129591529&server=cn_gf01";
        String ds = MD5.create().digestHex(StrUtil.format("salt={}&t={}&r={}&b={}&q={}",n,t,r,b,q));
        String ds2 = t+","+r+","+ds;
        System.out.println(ds2);

        String body = HttpRequest.get("https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/index?role_id=129591529&server=cn_gf01")
                .header("x-rpc-app_version", "2.37.1")
                .header("x-rpc-client_type", "5")
                .header("User-Agent", User_Agent)
                .header("Referer", "https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true&act_id=e202009291139501&utm_source=bbs&utm_medium=mys&utm_campaign=icon")
                .header("DS", ds2)
                .header("Cookie", "ltoken=QvIiBJo7MKr4c9BBWEPIF6HHlydb11dAHDfd5EMe;ltuid=215701871;cookie_token=sCPJ6yxOsoiGadJhS1RlcqrTkGS8uoCIGsIiOgs4; account_id=215701871;")
                .execute().body();

        System.out.println("body---------"+body);

    }
}
